//import java.applet.*;
import java.awt.*;

public class timer extends Panel{
	
	Label info, title, subtitle;
	public static Label timer;
	Label t1,t2,t3,t4,t5;
	Button next;
	int tstopCount=-1;
	clock a,b,c;
	public static void main(String[] args) {
		  Frame f = new Frame();
		  f.addWindowListener(new java.awt.event.WindowAdapter() {
		       public void windowClosing(java.awt.event.WindowEvent e) {
		       System.exit(0);
		       };
		     });
		  
		  timer t=new timer();
		  f.add(t);
		  f.pack();
		  t.init();
		  f.setSize(600,500 + 20); // add 20, seems enough for the Frame title,
		  f.show();
		  t.start();

	
	
	
	}


	public void init(){
		
	}
	
	public void start(){
		this.setLayout(new FlowLayout());

		this.setSize(500,400);
		Font bigFont = new Font("sansseriff",Font.BOLD,30);
		Font smaller = new Font("sansseriff",Font.BOLD,24);
		Font smallest = new Font("sansseriff",Font.BOLD,12);
	
		add(info = new Label("Live Timer:"));add(timer=new Label("00:00:00.00"));
		add(title=new Label("JavaTimer"));add(subtitle=new Label("by Dongsheng Ruan"));
		add(t1=new Label("RF Disconnected For - 00:00:00.00"));add(t2=new Label("OMP Banner Seen At - 00:00:00.00"));add(t3=new Label("A/V Recovered After - 00:00:00.00"));
		add(t4=new Label("TSB Recovered After - 00:00:00.00"));add(t5=new Label("VoD Recovered After - 00:00:00.00"));
		add(next=new Button("Click Me When You Disconnect the RF!"));
		
		title.setAlignment(Label.LEFT);subtitle.setAlignment(Label.LEFT);
		timer.setAlignment(Label.RIGHT);info.setAlignment(Label.CENTER);
		t1.setAlignment(Label.RIGHT);t2.setAlignment(Label.RIGHT);t3.setAlignment(Label.RIGHT);
		t4.setAlignment(Label.RIGHT);t5.setAlignment(Label.RIGHT);
		
		title.setFont(bigFont);subtitle.setFont(smallest);
		timer.setFont(bigFont);info.setFont(smaller);next.setFont(smaller);
		t1.setFont(bigFont);t2.setFont(bigFont);t3.setFont(bigFont);
		t4.setFont(bigFont);t5.setFont(bigFont);
		
		title.setBounds(0,5,500,30);subtitle.setBounds(0,30,500,30);
		info.setBounds(250,5,250,30);timer.setBounds(250,35,250,30);
		t1.setBounds(0,100,500,30);t2.setBounds(0,140,500,30);t3.setBounds(0,180,500,30);
		t4.setBounds(0,220,500,30);t5.setBounds(0,260,500,30);
		
		next.setBounds(0,300,500,200);
	}
	
	public boolean handleEvent(Event event){
		if(event.target==next && event.id==Event.ACTION_EVENT){
			if(tstopCount==-1){
				next.setLabel("Click Me When OMP Shows!");
				tstopCount++;
				a = new clock();
				a.start();			
			}
			else if(tstopCount==1){
				a.count=false;
				tstopCount++;
				next.setLabel("Click Me When A/V Recovers!");
				t1.setText("RF Disconnected For - " + timer.getText());
				try{
					Thread.sleep(100);
				}catch(Exception e){
					;
				}
				b = new clock();
				b.start();
			}
			else if(tstopCount==0){
				tstopCount++;
				next.setLabel("Click Me When You Reconnect the RF!");
				t2.setText("OMP Banner Seen At - " + timer.getText());
				try{
					Thread.sleep(100);
				}catch(Exception e){
					;
				}
			}
			else if(tstopCount==2){
				tstopCount++;
				next.setLabel("Click Me When TSB Recovers!");
				t3.setText("A/V Recovered After - " + timer.getText());
				try{
					Thread.sleep(100);
				}catch(Exception e){
					;
				}

			}
			else if(tstopCount==3){
				tstopCount++;
				next.setLabel("Click Me When VoD Recovers!");
				t4.setText("TSB Recovered After - " + timer.getText());
				try{
					Thread.sleep(100);
				}catch(Exception e){
					;
				}
			}
			else if(tstopCount==4){
				b.count=false;
				tstopCount++;
				t5.setText("VoD Recovered After - " + timer.getText());
				try{
					Thread.sleep(100);
				}catch(Exception e){
					;
				}
				next.setLabel("Click Me to Reset!");
			}
			else if(tstopCount==5){
				tstopCount=-1;
				next.setLabel("Click Me When You Disconnect the RF!");
				timer.setText("00:00:00.00");
				t1.setText("RF Disconnected For - 00:00:00.00");
				t2.setText("OMP Banner Seen At - 00:00:00.00");
				t3.setText("A/V Recovered After - 00:00:00.00");
				t4.setText("TSB Recovered After - 00:00:00.00");
				t5.setText("VoD Recovered After - 00:00:00.00");
			}
		}
		
		return super.handleEvent(event);
	}
}
